package com.zl.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zl.common.enumType.Category;
import com.zl.common.enumType.Column;
import com.zl.common.enumType.PublicDate;
import com.zl.dao.SelectorDao;
import com.zl.entity.City;
import com.zl.entity.Entity;
import com.zl.entity.Province;

/**   
* @Title: SelectorService.java 
* @Package com.zl.service 
* @Description:  
* @author chxl   
* @date 2015年8月4日 下午3:36:14 
* @version V1.0   
*/
@Service
public class SelectorService {
	@Autowired
	private SelectorDao selectorDao;
	public List<Province> getAllProvince(){
		return selectorDao.getAllProvince();
	}
	
	public List<City> getCity(String provinceId){
		return selectorDao.getCity(provinceId);
	}
	
	public City getCityById(String id){
		return selectorDao.getCityById(id);
	}
	
	public Province getProvinceById(String id){
		return selectorDao.getProvinceById(id);
	}
	
	public List<Entity> getCategoryList(){
		List<Entity> categoryList = new ArrayList<Entity>(Category.values().length);
		for (Category t : Category.values()) {
			Entity entity = new Entity();
			entity.setId(t.getCode());
			entity.setName(t.getName());
			categoryList.add(entity);
		}
		return categoryList;
	}
	
	public List<Entity> getColumnList(){
		List<Entity> columnList = new ArrayList<Entity>(Column.values().length);
		for (Column t : Column.values()) {
			Entity entity = new Entity();
			entity.setId(t.getCode());
			entity.setName(t.getName());
			columnList.add(entity);
		}
		return columnList;
	}
	
	public List<Entity> getPublicDateList(){
		List<Entity> publicDateList = new ArrayList<Entity>(PublicDate.values().length);
		for (PublicDate t : PublicDate.values()) {
			Entity entity = new Entity();
			entity.setId(Integer.toString(t.getOrdinal()));
			entity.setName(t.getName());
			publicDateList.add(entity);
		}
		return publicDateList;
	}
	
	public List<City> getCityByColumnId(String columnId){
		return selectorDao.getCityByColumnId(columnId);
	}
	
	/**
	 * 根据mingcheng获得城市
	 * @return
	 */
	public City getCityByName(String cityName){
		return selectorDao.getCityByName(cityName);
	}
}
